// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async(event, context) => {
  const wxContext = cloud.getWXContext()
  const db = cloud.database()
  const eventco=db.collection("event")
  const user = db.collection('user')

  console.log ('openid '+event.openid)
  console.log('mynewevents' + event.mynewevents)
  try{
    await eventco.doc(event.id).update({
      data:{
        feedback:event.feed
      }
    })
 
   
    await user.where({
      _openid:event.openid
    }).update({
      data:{
        myevents:event.mynewevents
      }
    })

  }catch(err){
    return {err}
  }
  return {
    event
  }
}